<template>
	<div>
		<el-row>
			<el-col :span="8" class="box">
				<ECharts :option="option" />
			</el-col>
			<el-col :span="8" class="box">
				<ECharts :option="option1" />
			</el-col>
			<el-col :span="8" class="box">
				<ECharts :option="option2" />
			</el-col>
		</el-row>
	</div>
</template>


<script lang="ts" setup>
import { onMounted, ref } from 'vue'
import axios from 'axios'
const option = ref({})

const option1 = {
	xAxis: {
		type: 'category',
		data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
	},
	yAxis: {
		type: 'value'
	},
	series: [
		{
			data: [150, 230, 224, 218, 135, 147, 260],
			type: 'line'
		}
	]
};

const option2 = {
	tooltip: {
		trigger: 'item'
	},
	legend: {
		top: '5%',
		left: 'center'
	},
	series: [
		{
			name: 'Access From',
			type: 'pie',
			radius: ['40%', '70%'],
			avoidLabelOverlap: false,
			itemStyle: {
				borderRadius: 10,
				borderColor: '#fff',
				borderWidth: 2
			},
			label: {
				show: false,
				position: 'center'
			},
			emphasis: {
				label: {
					show: true,
					fontSize: '40',
					fontWeight: 'bold'
				}
			},
			labelLine: {
				show: false
			},
			data: [
				{ value: 1048, name: 'Search Engine' },
				{ value: 735, name: 'Direct' },
				{ value: 580, name: 'Email' },
				{ value: 484, name: 'Union Ads' },
				{ value: 300, name: 'Video Ads' }
			]
		}
	]
};

onMounted(() => {
	axios.get('/api/echarts/age').then(resp => {
		option.value = resp.data.data
	})
})

</script>

<style>
.box {
	height: 500px;
}
</style>